﻿Imports System.Web.UI
Imports System.Collections.Generic
Imports SISSAT.WebDevelopment.Views
Imports SISSAT.BusinessLayer.Views
Imports SISSAT.BusinessLayer.DataViews

Namespace [Shared].UserControls
    Public Class SubjectListControl
        Inherits UserControl
        Implements ISubjectListControlView

        Property Presenter As SubjectListControlPresenter
        Property HasStudents As Boolean

        Public ReadOnly Property EmployeeCode As String Implements ISubjectListControlView.EmployeeCode
            Get
                Return SISSATPageBase.User.Employee.EmployeeCode
            End Get
        End Property

        Public ReadOnly Property SelectedValue As String Implements ISubjectListControlView.SelectedValue
            Get
                Return SchoolYearDropDownList.SelectedControlValue
            End Get
        End Property

        Public WriteOnly Property DropDownListDataSource As IEnumerable(Of KeyValuePair(Of String, String)) Implements ISubjectListControlView.DropDownListDataSource
            Set(value As IEnumerable(Of KeyValuePair(Of String, String)))
                SchoolYearDropDownList.DataSource = value
            End Set
        End Property

        Public WriteOnly Property RepeaterDataSource As IEnumerable(Of SubjectListDataView) Implements ISubjectListControlView.RepeaterDataSource
            Set(value As IEnumerable(Of SubjectListDataView))
                SubjectRepeater.DataSource = value
                SubjectRepeater.DataBind()
            End Set
        End Property

        Public Event OnInitialization() Implements ISubjectListControlView.OnInitialization
        Public Event OnSelectedIndexChange() Implements ISubjectListControlView.OnSelectedIndexChange

        Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
            Presenter = New SubjectListControlPresenter(Me)

            RaiseEvent OnInitialization()
            RaiseEvent OnSelectedIndexChange()
        End Sub

        Protected Sub SelectedIndexChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles schoolYearDropDownList.SelectedIndexChanged
            RaiseEvent OnSelectedIndexChange()
        End Sub

    End Class
End Namespace
